﻿<vw:View x:Class="Modules.AccountMgmt.AccountView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:vw="clr-namespace:sonic.Samples.Infrastructure.Views;assembly=Infrastructure"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions >
            <RowDefinition Height="200"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderThickness="1" CornerRadius="5" Margin="0,0,0,10" HorizontalAlignment="Left">
            <StackPanel Orientation="Vertical" Width="500">
                <toolkit:DataForm x:Name="AddNewDataForm" CurrentItem="{Binding CurrentAccount, Mode=TwoWay}" ItemsSource="{Binding Accounts, Mode=TwoWay}" 
                     HorizontalAlignment="Left" Width="500" >
                    <toolkit:DataForm.EditTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <toolkit:DataField>
                                    <TextBox Text="{Binding FirstName, Mode=TwoWay}" MinWidth="200" />
                                </toolkit:DataField>
                                <toolkit:DataField>
                                    <TextBox Text="{Binding LastName, Mode=TwoWay}" />
                                </toolkit:DataField>
                                <toolkit:DataField>
                                    <TextBox x:Name="AddressTextBox" Text="{Binding Address, Mode=TwoWay}" />
                                </toolkit:DataField>
                            </StackPanel>
                        </DataTemplate>
                    </toolkit:DataForm.EditTemplate>
                </toolkit:DataForm>
                <Button x:Name="FindCoordinatesButton" Content="Resolve Address" 
                        cal:Click.Command="{Binding FindCoordinatesCommand}" 
                        cal:Click.CommandParameter="{Binding CurrentAccount}"
                        Height="25" HorizontalAlignment="Right" Margin="0,5,0,0" />
            </StackPanel>
        </Border>
        <sdk:DataGrid Grid.Row="1" ItemsSource="{Binding Accounts}" SelectedItem="{Binding CurrentAccount, Mode=TwoWay}" AutoGenerateColumns="False" >
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="First Name" Binding="{Binding FirstName}"/>
                <sdk:DataGridTextColumn Header="Last Name" Binding="{Binding LastName}"/>
                <sdk:DataGridTextColumn Header="Address" Binding="{Binding Address}"/>
                <sdk:DataGridTextColumn Header="Latitude"  IsReadOnly="True" Binding="{Binding CurrentLocation.Latitude, Mode=OneWay}"/>
                <sdk:DataGridTextColumn Header="Longitude" IsReadOnly="True" Binding="{Binding CurrentLocation.Longitude, Mode=OneWay}" />
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
    </Grid>
</vw:View>
